from django.db import models
import uuid
from common.mixins.app_model_mixin import AppModelMixin
from django.core import cache

class ApplicationSetting(AppModelMixin):
    id = models.UUIDField(primary_key=True, max_length=128, default=uuid.uuid1, editable=False, verbose_name="主键id")
    application_id = models.CharField(unique=True, max_length=128,  verbose_name="应用ID")
    show_guide = models.BooleanField(default=False, verbose_name="是否显示引导")
    show_history = models.BooleanField(default=False, verbose_name="是否历史记录")
    avatar = models.CharField(max_length=128, verbose_name="AI头像", default="")
    user_avatar = models.CharField(max_length=128, verbose_name="提问用户头像", default="")
    float_icon = models.CharField(max_length=128, verbose_name="入口图标", default="")
    disclaimer = models.BooleanField(default=False, verbose_name="免责声明")
    disclaimer_value =  models.CharField(max_length=128, verbose_name="免责声明内容", default="")
    draggable = models.BooleanField(default=False, verbose_name="是否可拖动")
    float_location = models.JSONField(max_length=1024, verbose_name="位置", null=True)
    custom_theme = models.JSONField(max_length=1024, verbose_name="自定义主题", null=True)

    show_source = models.BooleanField(default=False, verbose_name="是否显示知识来源")

    language = models.CharField(max_length=10, verbose_name="语言", default=None, null=True)

    class Meta:
        db_table = "application_setting"

class XpackCache():
    def get(self, key, default=False):
        xpack_cache = cache.caches['user_cache']
        return xpack_cache
        

class application():
    def get_model_dict(self):
        return {
            'application_setting': ApplicationSetting,
            'xpack_cache': XpackCache
        }
    def __init__(self):
        pass
    def __call__(self):
        return self